//
//  BaseTabBarController.m
//  XKStudyDemo
//
//  Created by xukai on 2017/11/27.
//  Copyright © 2017年 xukai. All rights reserved.
//

#import "BaseTabBarController.h"
#import "HomeViewController.h"
#import "BaseNavigationController.h"
#import "DiscoverViewController.h"

@interface BaseTabBarController ()

@property (nonatomic, strong) HomeViewController *homeVC;
@property (nonatomic, strong) DiscoverViewController *discoverVC;

@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _homeVC = [[HomeViewController alloc] init];
    _discoverVC = [[DiscoverViewController alloc] init];
    
    
    [self setUpOneChildViewController:_homeVC image:[UIImage imageNamed:@"tabbar_home"] selectedImage:[UIImage imageNamed:@"tabbar_home_selected"] title:@"Home"];
    
    [self setUpOneChildViewController:_discoverVC image:[UIImage imageNamed:@"tabbar_discover"] selectedImage:[UIImage imageNamed:@"tabbar_discover_selected"] title:@"Discover"];

}

- (void)setUpOneChildViewController:(UIViewController *)vc image:(UIImage *)image selectedImage:(UIImage *)selectedImage title:(NSString *)title
{
    BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
    nav.tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:image selectedImage:selectedImage];
    [nav.tabBarItem setTitleTextAttributes:@{
                                             NSFontAttributeName :            [UIFont systemFontOfSize:10],
                                             NSForegroundColorAttributeName : [UIColor orangeColor]
                                             } forState:UIControlStateSelected];
    [self addChildViewController:nav];

}


@end
